﻿/// <reference path="tfcore.js"/>
/*
* This file has been commented to support Visual Studio Intellisense.
* You should not use this file at runtime inside the browser--it is only
* intended to be used only for design-time IntelliSense.  
*
* Comment version: 1.0a
*/

// #pragma NoCompStart
/*
appcommon-vsdoc.js  2.0a
specific functions for the GSF application content windows
*/
// #pragma NoCompEnd
//NameSpaces defined
_TF = top;
TF = document;
TF.APP = {};
TF.APP.Common = {};
if (false) {
    _TF.is = {};
    _TF.is.ff = {};
}
//_TF.Common.debug = function(msg) { edNLog.debug(msg, "debug"); };
TF.APP.Common.getContentElem = function(elID) {
    ///<summary>Get an element reference from the "content" page</summary>
    ///<param name="edID">ID of the element to retrieve</param>
    ///<returns>element object</returns>
    return frames['ifMainContent']._gE(elID);
};

TF.APP.Common.contentReload = function() {
    ///<summary>Reloads the content IFrame page from src</summary>
    ///<returns>None.</returns>
    _gE('ifMainContent').src = _gE('ifMainContent').src;
};

TF.APP.Common.contentPostBack = function(elTarget, elArgument) {
    ///<summary>Causes a Postback to occur on the Content IFrame page while passing in the target and argument for the postback</summary>
    ///<param name="elTarget">target control name that you want to pass</param>
    ///<param name="elArgument">argument you want to send to the postback (retirevable via EVENTARGUMENT querystring</param>
    ///<returns>None.</returns>
    frames['ifMainContent'].__doPostBack(elTarget, elArgument);
};

TF.APP.Common.contentRedirect = function(newURL) {
    ///<summary>Redirects the content IFrame page to a new URL</summary>
    ///<returns>None.</returns>
    _gE('ifMainContent').src = newURL;
};

//passthrough functions
TF.APP.Common.setFocus = function(elementId, frameName) {
    setFocus(elementId, frameName);
};

TF.APP.Common.elemStatus = function(strClientId, blnDisabled) {
    _gE(strClientId).disabled = blnDisabled;
};

TF.APP.Common.SetDialogTitle = function() {
    ///<summary>Sets the Main screens Title</summary>
    ///<returns>None.</returns>
    SetDialogTitle();
}
TF.APP.Common.cShowError = function(txtMessage, iType, callBackFunc) {
    ///<summary>Client Side ShowError</summary>
    ///<param name="txtMessage">The text of the error message to display</param>
    ///<param name="iType">The type of error message: alertTypes = { Error: 1, Warning: 2, Information: 3 } </param>
    ///<param name="callBackFunc">A optional function to run after the message is closed.</param>
    ///<returns>None.</returns>
    _TF.APP.Main.ShowError(txtMessage, iType, callBackFunc);
};

TF.APP.Common.elemReadOnly = function(strClientId, blnDisabled) {
    elemReadOnly(strClientId, blnDisabled);
};


//    if (_TF.is.ff) {
//        HTMLElement.prototype.click = function() {
//            var evt = document.createEvent('MouseEvents');
//            evt.initMouseEvent('click', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
//            this.dispatchEvent(evt);
//        };
//    }

stdOnUnload = function() { };
stdOnload = function() {
    var replaceTitle;
    if (document.forms[0]) { document.forms[0].disabled = false; }
    var metaTag = document.getElementsByName('MESTitle');
    if (metaTag.length > 0) { replaceTitle = metaTag[0].content; metaTag = null; }
    if (replaceTitle != "false" && _TF.PageTitle) { _TF.PageTitle.innerText = document.title; }
    else if (replaceTitle == "false" && _TF.PageTitle) { SetDialogTitle(); }
    if (typeof _TF["CloseAllErrors"] == 'function') { _TF.CloseAllErrors(); }
    if (typeof _TF["SessionRefresh"] == 'function') { _TF.SessionRefresh(); }
    if (typeof LocalOnLoad == 'function') { LocalOnLoad(); }
};

_addDOMLoadEvent(stdOnload);
//    _AddEvent(window, 'load', stdOnload);
_AddEvent(window, 'unload', stdOnUnload);
//    _TF.Shortcut.add("esc", closeModalDialog);
